//
//  OrderCell.swift
//  ShopCarDemo
//
//  Created by Rookie_YX on 16/6/21.
//  Copyright © 2016年 YX_Rookie. All rights reserved.
//

import UIKit

enum ButtonType: Int{
    case show, hidden
}
class OrderCell: UITableViewCell {
    
    var shopTitleL = UILabel()
    var selectedBtn = UIButton()
    
    init(style: UITableViewCellStyle, reuseIdentifier: String?, type:ButtonType) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        switch type {
        case ButtonType.show:
            
            addSubview(titleLabel)
            addSubview(selctedBtn)
            titleLabel.snp_makeConstraints { (make) in
                make.left.top.equalTo(self).offset(5)
                make.height.equalTo(30)
                make.right.equalTo(selctedBtn.snp_left)
                make.width.equalTo(200)
                make.bottom.equalTo(self).offset(-5)
            }
            selctedBtn.snp_makeConstraints { (make) in
                make.right.equalTo(self).offset(-10)
                make.top.bottom.equalTo(titleLabel)
                make.width.equalTo(40)
                make.height.equalTo(40)
            }
        case ButtonType.hidden:

            addSubview(titleLabel)
            titleLabel.snp_makeConstraints { (make) in
                make.left.top.equalTo(self).offset(5)
                make.height.equalTo(30)
                make.width.equalTo(240)
                make.bottom.equalTo(self).offset(-5)
            }
        }

    }
    
   
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    // MARK:- 懒加载
    private lazy var titleLabel:UILabel = {
        let lab = UILabel()
        lab.textColor = UIColor.blackColor()
        lab.font = UIFont.systemFontOfSize(14)
        self.shopTitleL = lab
        return lab
    }()

    private lazy var selctedBtn:UIButton = {
        let btn = UIButton()
        btn.setImage(UIImage(named:"btn_selected"), forState: UIControlState.Normal)
        btn.layer.masksToBounds = true
        btn.layer.cornerRadius = btn.bounds.width / 2
        self.selectedBtn = btn
        return btn
    }()

}
